<?php

/**
 * memberzoneComments actions.
 *
 * @package    jobeet
 * @subpackage memberzoneComments
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class memberzoneCommentsComponents extends myComponents
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeRender()
  {
	  $this->comments = $this->getComments();

	  $products = array();
	  foreach($this->comments as $comment){
		  $products[$comment['Product']['id']] = $comment['Product'];
	  }


	  $this->productLinks = LinkGen::getInstance(LinkGen::PRODUCT)->collectionLinks($products);
	  
	  $this->node = $this->getRoute()->getObject();
  }

  public function getComments(){

	 return
	  Doctrine_Query::create()
		->select('pc.*, p.*, t.*')
		->from('ProductComment pc')
		->where('pc.user_id = ?', $this->getUser()->getObject()->getId())
		->innerJoin('pc.Product p')
		->innerJoin('p.Translation t')
		->orderBy('pc.created_at desc')
		->execute();
  }

  
}
